package com.lkd.controller;


import com.lkd.entity.SkuClass;
import com.lkd.service.SkuClassService;
import com.lkd.vo.PageBean;
import com.lkd.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商品类别表 前端控制器
 * </p>
 *
 * @author 聂德祥
 * @since 2024-08-17
 */
@RestController
public class SkuClassController {

    @Autowired
    private SkuClassService skuClassService;
    @PostMapping("/api/vm-service/skuClass")
    public Result save(@RequestBody SkuClass skuClass){
        skuClassService.save(skuClass);
        return Result.success();
    }
    @GetMapping("/api/vm-service/skuClass/search")
    public Result findByPage(String className,@RequestParam(defaultValue = "1") Integer pageIndex,@RequestParam(defaultValue = "10") Integer pageSize){
        PageBean<SkuClass> page = skuClassService.findByPage(className,pageIndex,pageSize);
        return Result.success(page);
    }
    @GetMapping("/api/vm-service/skuClass/{classId}")
    public Result findByClassId(@PathVariable Long classId){
        skuClassService.getById(classId);
        return Result.success();
    }
    @PutMapping("/api/vm-service/skuClass")
    public Result updateById(@RequestBody SkuClass skuClass){
        skuClassService.updateById(skuClass);
        return Result.success();
    }
    @DeleteMapping("/api/vm-service/skuClass/{classId}")
    public Result deleteByClassId(@PathVariable Long classId){
        skuClassService.removeById(classId);
        return Result.success();
    }

}
